% ConstantDefinition.m

function ConstantDefinition()
% ConstantDefinition 设置全局常量并保存在ConstantDefinition.mat里，用到时load即可

    % 6.2.1

    % F调唱名对应频率
    % 行：大字组，小字组，小字一组，小字二组
    FRE_F = [
             87.31, 98, 110, 116.54, 130.81, 146.83, 164.81;
             174.61, 196, 220, 233.08, 261.63, 293.66, 329.63;
             349.23, 392, 440, 466.16, 523.25, 587.33, 659.25;
             698.46, 783.99, 880, 932.33, 1046.50, 1174.66, 1318.51;
             ];

    % used in function SingleSound
    PHI = 0;                % 初始相位
    TurnPoint1 = 0.05;      % 转折点
    TurnPoint2 = 0.05;
    TurnPoint3 = 0.5;
    Arate = 1.25;            % 最大值占平稳时幅值的比率

    HarmAmp1 = 0.2;         % 第一泛音列幅值占基音的幅值比例
    HarmAmp2 = 0.3;         % 第二泛音列幅值占基音的幅值比例

    % used in function SoundSynthesis
    SampRate = 44100;       % 采样率
    OverlapRate = 0.2;      % 重叠率，与前一个音有所重叠

    % 6.2.2
    

    save("..\data\ConstantDefinition.mat", "FRE_F", "PHI", "TurnPoint1", "TurnPoint2", "TurnPoint3", "Arate", ...
        "SampRate", "OverlapRate", "HarmAmp1", "HarmAmp2");
end